#ifndef __PKMNONLINE_PACKET_H__
#define __PKMNONLINE_PACKET_H__
#ifndef WIN32_LEAN_AND_MEAN
#	define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock2.h>
#include <stdlib.h>
#include <string.h>

class CPacket {
public:
	CPacket(const char *pData, u_int nLen);
	CPacket(u_int nLen);
	~CPacket();
	
	u_int GetSize() const { return m_nSize; }
	u_int GetContentSize() const { return m_nPos; }
	char *GetData() const { return m_pData; }

	void	Write(u_char nValue);
	void	Write(u_short nValue);
	void	Write(u_int nValue);
	void	Write(const char *pData, u_int nLen);
	void	Write(const char *szText);
	void	Write(char nValue) { Write((u_char)nValue); }
	void	Write(short nValue) { Write((u_short)nValue); }
	void	Write(int nValue) { Write((u_int)nValue); }

	u_char	ReadByte();
	u_short ReadShort();
	u_int	ReadInt();
	void	ReadBytes(char *pDest, u_int nLen);
	u_int	ReadString(char *szDest, u_int nMaxLen);


private:
	u_int m_nSize;
	u_int m_nPos;
	char *m_pData;
};

#endif /* __PKMNONLINE_PACKET_H__ */
